/*
 *
36
num = 67, ch = C
num = 1851877498, ch = z
name = zhangsan, age = 18
num = 69, ch = E

 */
#include<stdio.h>

struct person
{
	char name[16];
	int age;
	char sex;
	char phone[12];
};
union un
{
	int num;
	char ch;
	struct person student;
	struct person teacher;
}u2={69};//3.定义共用体结构时赋值

int main(){
	//1.定义共用体变量再赋值
	union un u;
	printf("%ld\n", sizeof(union un));
	u.num = 67;
	printf("num = %d, ch = %c\n",u.num, u.ch);

	//2. 定义共用体变量时赋值
	union un u1 = {
		.student.name = "zhangsan",
		.student.age = 18
	};
	printf("num = %d, ch = %c\n",u1.num, u1.ch);
	printf("name = %s, age = %d\n",u1.student.name, u1.student.age);

	//3.
	printf("num = %d, ch = %c\n",u2.num, u2.ch);
}
